package ass.web;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import ass.beans.UserFriendsBean;
import ass.dao.UserFriendsDAO;
import ass.dao.support.UserFriendsDAOImpl;

/**
 * Servlet implementation class ViewFrdRqst
 */
public class ViewFrdRqst extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ViewFrdRqst() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub

		HttpSession session = request.getSession(true);
		String username = (String) session.getAttribute("username");
		System.out.println(username);
		
		UserFriendsDAO userFriendsDAO = new UserFriendsDAOImpl();
//		UserFriendsBean userFriendsBean = new UserFriendsBean();
		List<UserFriendsBean> userFriendsList = userFriendsDAO.getFriend(username);
		
		
		List<UserFriendsBean> userInvitationList = userFriendsDAO.getInvitation(username);
//		System.out.println(userFriendsList);
//		
//		for (UserFriendsBean uBean : userFriendsList){
//			System.out.println(uBean.getUsername());
//			System.out.println(uBean.getMessage());
//		}
		
		String nextJSP = "/userFrdRequest.jsp";
		RequestDispatcher dispatcher = getServletContext()
				.getRequestDispatcher(nextJSP);
		request.setAttribute("userFriendsList", userFriendsList);
		request.setAttribute("userInvitationList", userInvitationList);
		dispatcher.forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
